package Cy.Servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import Cy.DAO.CommodityTypeDAO;
import Entity.CommodityType;
import Factory.CommodityTypeFactory;

/**
 * Servlet implementation class SelectCommodityTypeServlet
 */
@WebServlet("/selectcommoditytype")
public class SelectCommodityTypeServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private CommodityTypeDAO commoditytypeDAO = CommodityTypeFactory.createDAO();
	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String erorr =request.getParameter("erorr");
		List<CommodityType> list = commoditytypeDAO.selectctName();
		request.setAttribute("list", list);
		request.setAttribute("erorr", erorr);
		request.getRequestDispatcher("addCommodityType.jsp").forward(request, response);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		this.doGet(req, resp);
	}
}
